(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 11.2' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       158,          7]
NotebookDataLength[     67011,       1627]
NotebookOptionsPosition[     66676,       1612]
NotebookOutlinePosition[     67053,       1629]
CellTagsIndexPosition[     67010,       1626]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{
Cell[BoxData[
 RowBox[{"\[IndentingNewLine]", 
  RowBox[{
   RowBox[{
    RowBox[{
    "tmpfile", "=", 
     "\"\<C:/Users/surface/Desktop/\:58f0\:5e93/\:4e34\:65f6\>\""}], ";"}], 
   "\[IndentingNewLine]", 
   RowBox[{"(*", 
    RowBox[{
    "\:6307\:5b9a\:5b58\:653e\:58f0\:97f3\:632f\:5e45\:4e8c\:8fdb\:5236\:6587\
\:4ef6\:7684\:4e34\:65f6\:6587\:4ef6\:5939\:4f4d\:7f6e", ",", 
     "\:9700\:81ea\:884c\:4fee\:6539"}], "*)"}], "\[IndentingNewLine]", 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"ReadRealData", "[", "address_", "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"stream", "=", 
         RowBox[{"OpenRead", "[", 
          RowBox[{"address", ",", 
           RowBox[{"BinaryFormat", "\[Rule]", "True"}]}], "]"}]}], ",", 
        "data"}], "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"data", "=", 
        RowBox[{"BinaryReadList", "[", 
         RowBox[{"stream", ",", "\"\<Real64\>\""}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"Close", "[", "stream", "]"}], ";", "\[IndentingNewLine]", 
       "data"}]}], "]"}]}], "\[IndentingNewLine]", 
   RowBox[{"(*", "\[IndentingNewLine]", 
    RowBox[{
    "ReadRealData\:51fd\:6570", "\:ff1a", "\[IndentingNewLine]", 
     "\:8f93\:5165", "\:ff1a", 
     RowBox[{"address", "-", 
      RowBox[{"\:5b57\:7b26\:4e32", "\[IndentingNewLine]", "\:8f93\:51fa"}]}],
      "\:ff1a", 
     RowBox[{
     "\:4e00\:7ef4\:5b9e\:6570\:5217\:8868", "\[IndentingNewLine]", 
      "\:529f\:80fd"}], "\:ff1a", 
     "\:8bfb\:53d6\:5b58\:6709\:58f0\:97f3\:632f\:5e45\:6570\:636e\:7684\:4e8c\
\:8fdb\:5236\:6587\:4ef6"}], "\[IndentingNewLine]", "*)"}], 
   "\[IndentingNewLine]", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"WriteRealData", "[", 
     RowBox[{"address_", ",", "data_"}], "]"}], ":=", 
    RowBox[{"(", 
     RowBox[{
      RowBox[{"BinaryWrite", "[", 
       RowBox[{"address", ",", "data", ",", "\"\<Real64\>\""}], "]"}], ";", 
      RowBox[{"Close", "[", "address", "]"}], ";", "data"}], ")"}]}], 
   "\[IndentingNewLine]", 
   RowBox[{"(*", "\[IndentingNewLine]", 
    RowBox[{
    "WriteRealData\:51fd\:6570", "\:ff1a", "\[IndentingNewLine]", 
     "\:8f93\:5165", "\:ff1a", 
     RowBox[{"address", "-", "\:5b57\:7b26\:4e32"}], ",", 
     RowBox[{"data", "-", 
      RowBox[{
      "\:4e00\:7ef4\:5b9e\:6570\:5217\:8868", "\[IndentingNewLine]", 
       "\:8f93\:51fa"}]}], "\:ff1a", 
     RowBox[{
     "\:4e00\:7ef4\:5b9e\:6570\:5217\:8868", "\[IndentingNewLine]", 
      "\:529f\:80fd"}], "\:ff1a", 
     "\:5c06\:58f0\:97f3\:632f\:5e45\:6570\:636e\:5199\:5165\:4e8c\:8fdb\:5236\
\:6587\:4ef6"}], "\[IndentingNewLine]", "*)"}], "\[IndentingNewLine]", 
   "\[IndentingNewLine]", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Needs", "[", "\"\<NETLink`\>\"", "]"}], ";"}], 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"LoadNETAssembly", "[", "\"\<System.Speech\>\"", "]"}], ";"}], 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"TTSData", "[", 
     RowBox[{"string_", ",", 
      RowBox[{"speed_:", "0"}], ",", 
      RowBox[{"volume_:", "100"}], ",", 
      RowBox[{"samplerate_:", "44100"}], ",", 
      RowBox[{"sampledepth_:", "16"}], ",", 
      RowBox[{"channels_:", "1"}]}], "]"}], ":=", "\[IndentingNewLine]", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"address", "=", 
         RowBox[{"tmpfile", "<>", "\"\</\>\"", "<>", 
          RowBox[{"StringJoin", "@", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"ToString", "[", "#", "]"}], "&"}], "/@", 
             RowBox[{"Flatten", "[", 
              RowBox[{"{", 
               RowBox[{
               "string", ",", "speed", ",", "volume", ",", "samplerate", ",", 
                "sampledepth", ",", "channels"}], "}"}], "]"}]}], ")"}]}]}]}],
         "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
         "\:5f85\:751f\:6210\:6216\:8bfb\:53d6\:7684\:4e8c\:8fdb\:5236\:6587\
\:4ef6\:7684\:5730\:5740", 
          RowBox[{
          "(", "\:5728\:4e0a\:8ff0\:4e34\:65f6\:6587\:4ef6\:5939\:4e2d", 
           ")"}]}], "*)"}], ",", "tmpfile", ",", "synth", ",", "format", ",", 
        "data"}], "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"FileExistsQ", "[", "address", "]"}], "\[Equal]", "False"}], 
        ",", "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
         "\:5982\:679c\:4e0d\:5b58\:5728\:8be5\:4e8c\:8fdb\:5236\:6587\:4ef6",
           "\:ff0c", 
          "\:9700\:8981\:5148\:751f\:6210\:7136\:540e\:8bfb\:5165"}], "*)"}], 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"synth", "=", 
          RowBox[{
          "NETNew", "[", "\"\<System.Speech.Synthesis.SpeechSynthesizer\>\"", 
           "]"}]}], ";", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"synth", "@", "Rate"}], "=", "speed"}], ";", 
         RowBox[{"(*", "\:8bbe\:7f6e\:53d1\:97f3\:901f\:5ea6", "*)"}], 
         "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"synth", "@", "Volume"}], "=", "volume"}], ";", 
         RowBox[{"(*", "\:8bbe\:7f6e\:53d1\:97f3\:97f3\:91cf", "*)"}], 
         "\[IndentingNewLine]", 
         RowBox[{"format", "=", 
          RowBox[{"NETNew", "[", 
           RowBox[{
           "\"\<System.Speech.AudioFormat.SpeechAudioFormatInfo\>\"", ",", 
            "samplerate", ",", "sampledepth", ",", "channels"}], "]"}]}], ";",
          "\[IndentingNewLine]", 
         RowBox[{"(*", 
          RowBox[{
          "\:5b9a\:4e49\:751f\:6210\:97f3\:9891\:7684\:683c\:5f0f", "\:ff1a", 
           "\:91c7\:6837\:7387", "\:3001", 
           "\:91c7\:6837\:6df1\:5ea6\:548c\:58f0\:9053\:6570"}], "*)"}], 
         "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{"tmpfile", "=", 
          RowBox[{
           RowBox[{"Close", "@", 
            RowBox[{"OpenWrite", "[", "]"}]}], "<>", "\"\<.wav\>\""}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"synth", "@", 
          RowBox[{"SetOutputToWaveFile", "[", 
           RowBox[{"tmpfile", ",", "format"}], "]"}]}], ";", 
         RowBox[{
         "(*", "\:6307\:5b9a\:751f\:6210\:97f3\:9891\:7684\:4e34\:65f6\:6587\
\:4ef6\:5939\:548c\:683c\:5f0f", "*)"}], "\[IndentingNewLine]", 
         RowBox[{"synth", "@", 
          RowBox[{"Speak", "[", 
           RowBox[{"ToString", "[", "string", "]"}], "]"}]}], ";", 
         RowBox[{
         "(*", "\:6307\:5b9a\:53d1\:97f3\:5b57\:7b26\:4e32\:540e\:5408\:6210\
\:5e76\:8f93\:51fa", "*)"}], "\[IndentingNewLine]", 
         RowBox[{"synth", "@", 
          RowBox[{"Dispose", "[", "]"}]}], ";", "\[IndentingNewLine]", 
         RowBox[{"data", "=", 
          RowBox[{"First", "@", 
           RowBox[{"AudioData", "@", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"AudioTrim", "[", 
               RowBox[{"100", 
                RowBox[{"Import", "[", "tmpfile", "]"}]}], "]"}], "/", 
              "100"}], ")"}]}]}]}], ";", "\[IndentingNewLine]", 
         RowBox[{"(*", 
          RowBox[{
          "\:8bfb\:53d6\:97f3\:9891\:632f\:5e45\:6570\:636e", ",", 
           "\:53bb\:9664\:5934\:5c3e\:90e8\:4f4e\:97f3\:91cf\:7684\:90e8\:5206\
"}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{"DeleteFile", "[", "tmpfile", "]"}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"WriteRealData", "[", 
          RowBox[{"address", ",", "data"}], "]"}]}], "\[IndentingNewLine]", 
        RowBox[{
        "(*", "\:5c06\:632f\:5e45\:6570\:636e\:5199\:5165\:4e34\:65f6\:6587\
\:4ef6\:5939\:4e2d\:4e8c\:8fdb\:5236\:6587\:4ef6\:5e76\:8f93\:51fa", "*)"}], 
        "\[IndentingNewLine]", ",", "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
         "\:5982\:679c\:5b58\:5728\:8be5\:4e8c\:8fdb\:5236\:6587\:4ef6", 
          "\:ff0c", "\:76f4\:63a5\:8bfb\:53d6\:6570\:636e", "\:ff0c", 
          "\:8fd9\:6837\:53ef\:4ee5\:8282\:7701\:8ba1\:7b97\:65f6\:95f4"}], 
         "*)"}], "\[IndentingNewLine]", 
        RowBox[{"ReadRealData", "[", "address", "]"}]}], "]"}]}], "]"}]}], 
   "\[IndentingNewLine]", 
   RowBox[{"(*", "\[IndentingNewLine]", 
    RowBox[{
    "TTSData\:51fd\:6570", "\:ff1a", "\[IndentingNewLine]", "\:8f93\:5165", 
     "\:ff1a", 
     RowBox[{"string", "-", "\:5b57\:7b26\:4e32"}], ",", 
     RowBox[{"speed", "-", 
      RowBox[{"\:6574\:6570", 
       RowBox[{"(", 
        RowBox[{"-", 
         RowBox[{"10", "~", "10"}]}], ")"}]}]}], ",", 
     RowBox[{"volume", "-", 
      RowBox[{"\:6574\:6570", 
       RowBox[{"(", 
        RowBox[{
         RowBox[{"0", "~", "100"}], "\:ff0c", "\:63a8\:8350100"}], ")"}]}]}], 
     ",", 
     RowBox[{"samplerate", "-", 
      RowBox[{"\:6b63\:6574\:6570", 
       RowBox[{"(", "\:63a8\:835044100", ")"}]}]}], "\:ff0c", 
     RowBox[{"sampledepth", "-", 
      RowBox[{"\:6b63\:6574\:6570", 
       RowBox[{"(", "\:63a8\:835016", ")"}]}]}], "\:ff0c", 
     RowBox[{"channels", "-", 
      RowBox[{"\:6b63\:6574\:6570", 
       RowBox[{"(", "\:63a8\:83501", ")"}], "\[IndentingNewLine]", 
       "\:8f93\:51fa"}]}], "\:ff1a", 
     RowBox[{"\:4e00\:7ef4\:5b9e\:6570\:5217\:8868", 
      RowBox[{"(", 
       RowBox[{"\:8303\:56f4", "-", 
        RowBox[{"1", "~", "1"}]}], ")"}], "\[IndentingNewLine]", 
      "\:529f\:80fd"}], "\:ff1a", 
     "\:5229\:7528NETLink\:8c03\:7528\:5fae\:8f6f\:6167\:6167TTS\:751f\:6210\
\:97f3\:9891\:5e76\:83b7\:5f97\:58f0\:97f3\:632f\:5e45\:6570\:636e"}], 
    "\[IndentingNewLine]", "*)"}], "\[IndentingNewLine]", 
   "\[IndentingNewLine]", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"BaseF", "[", 
     RowBox[{"absdata_", ",", 
      RowBox[{"scanf_:", 
       RowBox[{"{", 
        RowBox[{"150", ",", "400"}], "}"}]}], ",", 
      RowBox[{"samplerate_:", "44100"}], ",", 
      RowBox[{"precision_:", "8"}], ",", 
      RowBox[{"flimit_:", "8000"}]}], "]"}], ":=", "\[IndentingNewLine]", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"n", "=", 
         RowBox[{"Length", "[", "absdata", "]"}]}], ",", "nlo", ",", "nup", 
        ",", "n1", ",", "n2", ",", "n3", ",", "amp1", ",", 
        RowBox[{"amp2", "=", "0"}], ",", 
        RowBox[{"amp3", "=", "0"}], ",", "nfirst", ",", "nlimit", ",", "dn", 
        ",", "ilist", ",", "nlist", ",", "amplist", ",", "ailist", ",", 
        "anlist", ",", "suma", ",", "sumai", ",", "suman", ",", "sumaii", ",",
         "sumain"}], "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"nlo", "=", 
        RowBox[{
         RowBox[{"Max", "[", 
          RowBox[{
           RowBox[{"Floor", "[", 
            RowBox[{
             RowBox[{"scanf", "[", 
              RowBox[{"[", "1", "]"}], "]"}], " ", 
             RowBox[{"n", "/", "samplerate"}]}], "]"}], ",", "0"}], "]"}], 
         "+", "1"}]}], ";", 
       RowBox[{"(*", "\:641c\:7d22\:8303\:56f4\:4e0b\:9650", "*)"}], 
       "\[IndentingNewLine]", 
       RowBox[{"nup", "=", 
        RowBox[{"Floor", "[", 
         RowBox[{"Min", "[", 
          RowBox[{
           RowBox[{
            RowBox[{"n", "/", "2"}], "+", "1"}], ",", 
           RowBox[{
            RowBox[{"scanf", "[", 
             RowBox[{"[", "2", "]"}], "]"}], " ", 
            RowBox[{"n", "/", "samplerate"}]}]}], "]"}], "]"}]}], ";", 
       RowBox[{"(*", "\:641c\:7d22\:8303\:56f4\:4e0a\:9650", "*)"}], 
       "\[IndentingNewLine]", 
       RowBox[{"n1", "=", 
        RowBox[{
         RowBox[{
          RowBox[{"Ordering", "[", 
           RowBox[{
            RowBox[{"absdata", "[", 
             RowBox[{"[", 
              RowBox[{"nlo", ";;", "nup"}], "]"}], "]"}], ",", 
            RowBox[{"-", "1"}]}], "]"}], "[", 
          RowBox[{"[", "1", "]"}], "]"}], "+", "nlo", "-", "1"}]}], ";", 
       RowBox[{"(*", "\:83b7\:53d6\:5cf0\:503c\:7684\:4f4d\:7f6e", "*)"}], 
       "\[IndentingNewLine]", 
       RowBox[{"amp1", "=", 
        SuperscriptBox[
         RowBox[{"Total", "[", 
          SuperscriptBox[
           RowBox[{"absdata", "[", 
            RowBox[{"[", 
             RowBox[{
              RowBox[{"n1", "-", "precision"}], ";;", 
              RowBox[{"n1", "+", "precision"}]}], "]"}], "]"}], "2"], "]"}], 
         "0.5"]}], ";", 
       RowBox[{
       "(*", "\:4f30\:7b97\:7b2c\:4e00\:4e2a\:5cf0\:7684\:6709\:6548\:632f\
\:5e45", "*)"}], "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{"n1", ">", 
          RowBox[{"2", 
           RowBox[{"(", 
            RowBox[{"nlo", "-", "1"}], ")"}]}]}], ",", 
         RowBox[{"(*", 
          RowBox[{
          "\:5982\:679c\:7b2c\:4e00\:4e2a\:5cf0\:7684\:4f4d\:7f6e\:6bd4\:641c\
\:7d22\:8303\:56f4\:4e0b\:9650\:76842\:500d\:8fd8\:5927", "\:ff0c", 
           "\:6709\:53ef\:80fd\:6211\:4eec\:6d4b\:5230\:7684\:4e0d\:662f\:57fa\
\:9891\:800c\:662f2\:500d\:57fa\:9891\:7684\:6cdb\:97f3\:5cf0"}], "*)"}], 
         "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"nlo", "=", 
           RowBox[{
            RowBox[{"Floor", "[", 
             RowBox[{"7", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"n1", "-", "1"}], ")"}], "/", "16"}]}], "]"}], "+", 
            "1"}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"nup", "=", 
           RowBox[{
            RowBox[{"Floor", "[", 
             RowBox[{"9", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"n1", "-", "1"}], ")"}], "/", "16"}]}], "]"}], "+", 
            "1"}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"n2", "=", 
           RowBox[{
            RowBox[{
             RowBox[{"Ordering", "[", 
              RowBox[{
               RowBox[{"absdata", "[", 
                RowBox[{"[", 
                 RowBox[{"nlo", ";;", "nup"}], "]"}], "]"}], ",", 
               RowBox[{"-", "1"}]}], "]"}], "[", 
             RowBox[{"[", "1", "]"}], "]"}], "+", "nlo", "-", "1"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"amp2", "=", 
           SuperscriptBox[
            RowBox[{"Total", "[", 
             SuperscriptBox[
              RowBox[{"absdata", "[", 
               RowBox[{"[", 
                RowBox[{
                 RowBox[{"n2", "-", "precision"}], ";;", 
                 RowBox[{"n2", "+", "precision"}]}], "]"}], "]"}], "2"], 
             "]"}], "0.5"]}]}]}], "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
         "\:5728\:5cf0\:6a2a\:5750\:6807\:4e00\:534a\:7684\:4f4d\:7f6e\:9644\
\:8fd1\:641c\:7d22", "\:ff0c", 
          "\:5f97\:5230\:65b0\:7684\:5cf0\:503c\:4f4d\:7f6e\:548c\:6709\:6548\
\:632f\:5e45"}], "*)"}], "\[IndentingNewLine]", "]"}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{"n1", ">", 
          RowBox[{"3", 
           RowBox[{"(", 
            RowBox[{"nlo", "-", "1"}], ")"}]}]}], ",", "\[IndentingNewLine]", 
         RowBox[{"(*", 
          RowBox[{
          "\:5982\:679c\:7b2c\:4e00\:4e2a\:5cf0\:7684\:4f4d\:7f6e\:6bd4\:641c\
\:7d22\:8303\:56f4\:4e0b\:9650\:76843\:500d\:8fd8\:5927", "\:ff0c", 
           "\:6709\:53ef\:80fd\:6211\:4eec\:6d4b\:5230\:7684\:4e0d\:662f\:57fa\
\:9891\:800c\:662f3\:500d\:57fa\:9891\:7684\:6cdb\:97f3\:5cf0"}], "*)"}], 
         "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"nlo", "=", 
           RowBox[{
            RowBox[{"Floor", "[", 
             RowBox[{"5", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"n1", "-", "1"}], ")"}], "/", "18"}]}], "]"}], "+", 
            "1"}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"nup", "=", 
           RowBox[{
            RowBox[{"Floor", "[", 
             RowBox[{"7", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"n1", "-", "1"}], ")"}], "/", "18"}]}], "]"}], "+", 
            "1"}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"n3", "=", 
           RowBox[{
            RowBox[{
             RowBox[{"Ordering", "[", 
              RowBox[{
               RowBox[{"absdata", "[", 
                RowBox[{"[", 
                 RowBox[{"nlo", ";;", "nup"}], "]"}], "]"}], ",", 
               RowBox[{"-", "1"}]}], "]"}], "[", 
             RowBox[{"[", "1", "]"}], "]"}], "+", "nlo", "-", "1"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"amp3", "=", 
           SuperscriptBox[
            RowBox[{"Total", "[", 
             SuperscriptBox[
              RowBox[{"absdata", "[", 
               RowBox[{"[", 
                RowBox[{
                 RowBox[{"n3", "-", "precision"}], ";;", 
                 RowBox[{"n3", "+", "precision"}]}], "]"}], "]"}], "2"], 
             "]"}], "0.5"]}]}]}], "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
         "\:5728\:5cf0\:6a2a\:5750\:6807\:4e09\:5206\:4e4b\:4e00\:7684\:4f4d\
\:7f6e\:9644\:8fd1\:641c\:7d22", "\:ff0c", 
          "\:5f97\:5230\:65b0\:7684\:5cf0\:503c\:4f4d\:7f6e\:548c\:6709\:6548\
\:632f\:5e45"}], "*)"}], "\[IndentingNewLine]", "]"}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"nfirst", "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"5", "amp3"}], ">", "amp1"}], " ", ",", "n3", ",", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"5", "amp2"}], ">", "amp1"}], ",", "n2", ",", "n1"}], 
           "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
        "\:6bd4\:8f83\:8fd9\:4e09\:4e2a\:6709\:6548\:632f\:5e45\:7684\:5927\
\:5c0f", "\:ff0c", 
         "\:627e\:5230\:771f\:6b63\:5bf9\:5e94\:57fa\:9891\:7684\:5cf0\:4f4d\
\:7f6e\:548c\:6709\:6548\:632f\:5e45"}], "*)"}], "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"nlimit", "=", " ", 
        RowBox[{
         RowBox[{"Floor", "[", 
          RowBox[{"flimit", " ", 
           RowBox[{
            RowBox[{"n", "/", "samplerate"}], "/", 
            RowBox[{"(", 
             RowBox[{"nfirst", "-", "1"}], ")"}]}]}], "]"}], "+", "1"}]}], 
       ";", "\[IndentingNewLine]", 
       RowBox[{"dn", "=", 
        RowBox[{"Floor", "[", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"nfirst", "-", "1"}], ")"}], "/", "2.5"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"ilist", "=", 
        RowBox[{"Range", "[", "nlimit", "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"nlist", "=", 
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{
           RowBox[{
            RowBox[{"Ordering", "[", 
             RowBox[{
              RowBox[{"absdata", "[", 
               RowBox[{"[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"i", " ", 
                   RowBox[{"(", 
                    RowBox[{"nfirst", "-", "1"}], ")"}]}], "+", "1", "-", 
                  "dn"}], ";;", 
                 RowBox[{
                  RowBox[{"i", " ", 
                   RowBox[{"(", 
                    RowBox[{"nfirst", "-", "1"}], ")"}]}], "+", "1", "+", 
                  "dn"}]}], "]"}], "]"}], ",", 
              RowBox[{"-", "1"}]}], "]"}], "[", 
            RowBox[{"[", "1", "]"}], "]"}], "+", 
           RowBox[{"i", " ", 
            RowBox[{"(", 
             RowBox[{"nfirst", "-", "1"}], ")"}]}], "-", "dn"}], ",", 
          RowBox[{"{", 
           RowBox[{"i", ",", "1", ",", "nlimit"}], "}"}]}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"amplist", "=", 
        SuperscriptBox[
         RowBox[{"Total", "[", 
          RowBox[{
           RowBox[{
            RowBox[{
             SuperscriptBox[
              RowBox[{"absdata", "[", 
               RowBox[{"[", 
                RowBox[{
                 RowBox[{"#", "-", "precision"}], ";;", 
                 RowBox[{"#", "+", "precision"}]}], "]"}], "]"}], "2"], "&"}],
             "/@", "nlist"}], ",", 
           RowBox[{"{", "2", "}"}]}], "]"}], "0.5"]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{
       "(*", "\:83b7\:5f97\:6307\:5b9a\:603b\:4e0a\:9650\:9891\:7387\:4ee5\
\:4e0b\:7684\:5404\:7ea7\:6cdb\:97f3\:7684\:4f4d\:7f6e\:548c\:6709\:6548\:632f\
\:5e45", "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"ailist", "=", 
        RowBox[{"amplist", " ", "ilist"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"anlist", "=", 
        RowBox[{"amplist", " ", "nlist"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"suma", "=", 
        RowBox[{"Total", "[", "amplist", "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"sumai", "=", 
        RowBox[{"Total", "[", "ailist", "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"suman", "=", 
        RowBox[{"Total", "[", "anlist", "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"sumaii", "=", 
        RowBox[{"Total", "[", 
         RowBox[{"ailist", " ", "ilist"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"sumain", "=", 
        RowBox[{"Total", "[", 
         RowBox[{"anlist", " ", "ilist"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{
          FractionBox[
           RowBox[{
            RowBox[{"suma", " ", "sumain"}], "-", 
            RowBox[{"sumai", " ", "suman"}]}], 
           RowBox[{
            RowBox[{"suma", " ", "sumaii"}], "-", 
            SuperscriptBox["sumai", "2"]}]], 
          FractionBox["samplerate", "n"]}], 
         RowBox[{"(*", 
          RowBox[{
          "\:62df\:5408\:8fd9\:4e9b\:6570\:636e", "\:ff0c", 
           "\:5f97\:5230\:66f4\:52a0\:7cbe\:51c6\:7684\:57fa\:9891\:7684\:5927\
\:5c0f"}], "*)"}], ",", 
         RowBox[{"Transpose", "[", 
          RowBox[{"{", 
           RowBox[{"nlist", ",", "amplist"}], "}"}], "]"}]}], 
        RowBox[{"(*", "\:5171\:632f\:5cf0\:6570\:636e", "*)"}], "}"}]}]}], 
     "]"}]}], "\[IndentingNewLine]", 
   RowBox[{"(*", "\[IndentingNewLine]", 
    RowBox[{
    "BaseF\:51fd\:6570", "\:ff1a", "\[IndentingNewLine]", "\:8f93\:5165", 
     "\:ff1a", 
     RowBox[{"absdata", "-", 
      RowBox[{"\:4e00\:7ef4\:6b63\:5b9e\:6570\:5217\:8868", 
       RowBox[{
       "(", "\:9ad8\:7cbe\:5ea6Fourier\:53d8\:6362\:540e\:53d6\:7edd\:5bf9\
\:503c\:5f97\:5230\:7684\:9891\:8c31\:6570\:636e", ")"}]}]}], ",", 
     RowBox[{"scanf", "-", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"\:6b63\:5b9e\:65701", ",", "\:6b63\:5b9e\:65702"}], "}"}], 
       RowBox[{"(", 
        RowBox[{
        "\:63a2\:6d4b\:9891\:7387\:7684\:4e0b\:9650\:548c\:4e0a\:9650", 
         "\:ff0c", 
         RowBox[{"\:63a8\:8350", 
          RowBox[{"{", 
           RowBox[{"150", ",", "400"}], "}"}]}]}], ")"}]}]}], ",", 
     RowBox[{"samplerate", "-", 
      RowBox[{"\:6b63\:6574\:6570", 
       RowBox[{"(", "\:63a8\:835044100", ")"}]}]}], "\:ff0c", 
     RowBox[{"precision", "-", 
      RowBox[{"\:6b63\:6574\:6570", 
       RowBox[{"(", 
        RowBox[{
        "\:53d6\:51b3\:4e8e\:9ad8\:7cbe\:5ea6Fourier\:53d8\:6362\:8fc7\:7a0b\
\:4e2d\:7ed3\:5c3e\:88650\:7684\:500d\:6570", "\:ff0c", "\:63a8\:83508"}], 
        ")"}]}]}], ",", 
     RowBox[{"flimit", "-", 
      RowBox[{"\:6b63\:5b9e\:6570", 
       RowBox[{"(", 
        RowBox[{
        "\:603b\:4e0a\:9650\:9891\:7387", "\:ff0c", "\:63a8\:83508000"}], 
        ")"}], "\[IndentingNewLine]", "\:8f93\:51fa"}]}], "\:ff1a", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"\:6b63\:5b9e\:6570", 
         RowBox[{"(", 
          RowBox[{
          "\:8868\:793a\:62df\:5408\:51fa\:7684\:57fa\:9891", "\:ff0c", 
           "\:5355\:4f4dHz"}], ")"}]}], ",", 
        RowBox[{"\:4e8c\:7ef4\:70b9\:5217", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{"\:6a2a\:5750\:6807\:5747\:4e3a\:6b63\:6574\:6570", 
            RowBox[{
            "(", "\:6ce8\:610f\:8fd9\:91cc\:4e0d\:662f\:9891\:7387\:800c\:662f\
\:65e0\:5355\:4f4d\:7684", ")"}]}], ",", 
           "\:7eb5\:5750\:6807\:5747\:4e3a\:6b63\:5b9e\:6570", "\:ff0c", 
           "\:7528\:4e8e\:62df\:5408\:5171\:632f\:5cf0"}], ")"}]}]}], "}"}], 
      "\[IndentingNewLine]", "\:529f\:80fd"}], "\:ff1a", 
     "\:7ed9\:5b9a\:9ad8\:7cbe\:5ea6Fourier\:53d8\:6362\:9891\:8c31\:6570\
\:636e", "\:ff0c", 
     "\:5f97\:5230\:5173\:4e8e\:57fa\:9891\:7684\:548c\:5171\:632f\:5cf0\:7684\
\:4fe1\:606f"}], "\[IndentingNewLine]", "*)"}], "\[IndentingNewLine]", 
   "\[IndentingNewLine]", 
   RowBox[{"(*", 
    RowBox[{
     RowBox[{"Needs", "[", "\"\<CCompilerDriver`\>\"", "]"}], ";", 
     "\[IndentingNewLine]", 
     RowBox[{"$CCompiler", " ", "=", " ", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{
        "\"\<Compiler\>\"", "->", 
         "CCompilerDriver`GenericCCompiler`GenericCCompiler"}], ",", " ", 
        RowBox[{
        "\"\<CompilerInstallation\>\"", "->", "\"\<C:/Dev-Cpp/MinGW64\>\""}], 
        ",", 
        RowBox[{
        "\"\<CompilerName\>\"", "->", 
         "\"\<x86_64-w64-mingw32-gcc.exe\>\""}]}], "}"}]}], ";", 
     RowBox[{"$CompilationTarget", "=", "\"\<C\>\""}], ";"}], "*)"}], 
   "\[IndentingNewLine]", 
   RowBox[{"(*", 
    RowBox[{
    "\:5982\:679c\:5b89\:88c5\:4e86C\:7f16\:8bd1\:5668\:5219\:53ef\:4ee5\:5c06\
\:4e0a\:9762\:7684\:4ee3\:7801\:53d6\:6d88\:6ce8\:91ca", "\:ff0c", 
     RowBox[{
     "\:5e76\:5c31\:5173\:4e8eC\:7f16\:8bd1\:5668\:53c2\:6570\:7684\:90e8\
\:5206", 
      RowBox[{"(", 
       RowBox[{"\[Rule]", "\:7684\:540e\:9762"}], ")"}], 
      "\:81ea\:884c\:4fee\:6539"}], "\:ff0c", 
     "\:8fd9\:6837\:4e0b\:9762\:7684\:51fd\:6570\:8fd0\:884c\:6548\:7387\:66f4\
\:597d"}], "*)"}], "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Resample", "=", 
     RowBox[{"Compile", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"list", ",", "_Real", ",", "1"}], "}"}], ",", 
         RowBox[{"{", 
          RowBox[{"scaled", ",", "_Real"}], "}"}]}], "}"}], ",", 
       RowBox[{"ArrayResample", "[", 
        RowBox[{"list", ",", 
         RowBox[{"Scaled", "[", "scaled", "]"}]}], "]"}], ",", 
       RowBox[{"\"\<RuntimeOptions\>\"", "\[Rule]", "\"\<Speed\>\""}]}], 
      "]"}]}], ";"}], "\[IndentingNewLine]", 
   RowBox[{"(*", "\[IndentingNewLine]", 
    RowBox[{
    "Resample\:51fd\:6570", "\:ff1a", "\[IndentingNewLine]", "\:8f93\:5165", 
     "\:ff1a", 
     RowBox[{"list", "-", "\:4e00\:7ef4\:5b9e\:6570\:5217\:8868"}], ",", 
     RowBox[{"scaled", "-", 
      RowBox[{"\:6b63\:5b9e\:6570", "\[IndentingNewLine]", "\:8f93\:51fa"}]}],
      "\:ff1a", 
     RowBox[{
     "\:4e00\:7ef4\:5b9e\:6570\:5217\:8868", "\[IndentingNewLine]", 
      "\:529f\:80fd"}], "\:ff1a", 
     RowBox[{"\:6570\:7ec4\:91cd\:91c7\:6837", 
      RowBox[{"(", "\:7ecf\:8fc7\:7f16\:8bd1\:52a0\:901f", ")"}]}]}], 
    "\[IndentingNewLine]", "*)"}], "\[IndentingNewLine]", 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Hamming", "[", "x_", "]"}], ":=", 
    RowBox[{"0.53836", "-", 
     RowBox[{"0.46164", 
      RowBox[{"Cos", "[", 
       RowBox[{"2", "\[Pi]", " ", "x"}], "]"}]}]}]}], 
   RowBox[{"(*", 
    RowBox[{
    "\:6c49\:660e\:7a97\:51fd\:6570", "\:ff0c", 
     "\:7ecf\:6d4b\:8bd5\:5b83\:7684\:6548\:679c\:6700\:597d"}], "*)"}], 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Windowlist", "[", 
     RowBox[{"length_", ",", 
      RowBox[{"windowfunction_:", "Hamming"}]}], "]"}], ":=", 
    RowBox[{"windowfunction", "[", 
     FractionBox[
      RowBox[{"Range", "[", "length", "]"}], 
      RowBox[{"length", "+", "1"}]], "]"}]}], 
   RowBox[{
   "(*", "\:751f\:6210\:79bb\:6563\:7684\:7a97\:51fd\:6570\:5b9e\:6570\:5217",
     "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"SortPoints", "[", 
     RowBox[{"pointlist_", ",", 
      RowBox[{"addpoints_:", "Nothing"}]}], "]"}], ":=", 
    RowBox[{"SortBy", "[", 
     RowBox[{
      RowBox[{"DeleteDuplicatesBy", "[", 
       RowBox[{
        RowBox[{"Flatten", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"pointlist", ",", "addpoints"}], "}"}], ",", "1"}], "]"}], 
        ",", 
        RowBox[{"N", "@*", "First"}]}], "]"}], ",", 
      RowBox[{"N", "@*", "First"}]}], "]"}]}], "\[IndentingNewLine]", 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"LineFunction", "[", 
     RowBox[{"pointlist_", ",", 
      RowBox[{"addpoints_:", "Nothing"}], ",", 
      RowBox[{"order_:", "1"}]}], "]"}], ":=", 
    RowBox[{"Interpolation", "[", 
     RowBox[{
      RowBox[{"SortPoints", "[", 
       RowBox[{"pointlist", ",", "addpoints"}], "]"}], ",", 
      RowBox[{"InterpolationOrder", "\[Rule]", "order"}]}], "]"}]}], 
   "\[IndentingNewLine]", 
   RowBox[{"(*", 
    RowBox[{
     RowBox[{"\:5728\:70b9\:5217\:4e2d\:6dfb\:52a0\:70b9", 
      RowBox[{"(", "\:4e5f\:53ef\:4ee5\:4e0d\:52a0", ")"}]}], "\:ff0c", 
     "\:6839\:636e\:6a2a\:5750\:6807\:5bf9\:70b9\:5217\:6392\:5e8f", "\:ff0c",
      "\:5220\:9664\:91cd\:590d\:70b9", "\:ff0c", 
     "\:7136\:540e\:7528\:591a\:9879\:5f0f\:62df\:5408\:8fd9\:4e9b\:70b9"}], 
    "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"KFResample", "[", 
     RowBox[{"data_", ",", "fgoal_", ",", "windowlist_", ",", 
      RowBox[{"scanf_:", 
       RowBox[{"{", 
        RowBox[{"150", ",", "400"}], "}"}]}], ",", 
      RowBox[{"flimit_:", "8000"}], ",", 
      RowBox[{"samplerate_:", "44100"}], ",", 
      RowBox[{"precision_:", "8"}]}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"energy", "=", 
         RowBox[{"Total", "[", 
          SuperscriptBox["data", "2"], "]"}]}], 
        RowBox[{"(*", "\:603b\:80fd\:91cf", "*)"}], ",", 
        RowBox[{"n", "=", 
         RowBox[{"Length", "[", "data", "]"}]}], ",", "nlo", ",", "fbase", 
        ",", "matrixn", ",", "fourier", ",", "newfourier", ",", "function", 
        ",", "nlist", ",", "nunit", ",", "ampshiftlist", ",", "nmid", ",", 
        "newnmid", ",", "dn", ",", "newdata", ",", "newenergy"}], "}"}], ",", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"newfourier", "=", 
        RowBox[{"fourier", "=", 
         RowBox[{"ConstantArray", "[", 
          RowBox[{"0", ",", 
           RowBox[{"n", "*", "precision"}]}], "]"}]}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"fourier", "[", 
         RowBox[{"[", 
          RowBox[{";;", "n"}], "]"}], "]"}], "=", 
        RowBox[{"windowlist", 
         RowBox[{"(*", "\:52a0\:7a97", "*)"}], " ", "data"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"fourier", "=", 
        RowBox[{"Fourier", "[", "fourier", "]"}]}], ";", 
       RowBox[{
       "(*", "\:52a0\:7a97\:540e\:7684\:9ad8\:7cbe\:5ea6\:5085\:91cc\:53f6\
\:53d8\:6362", "*)"}], "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"{", 
         RowBox[{"fbase", ",", "matrixn"}], "}"}], "=", 
        RowBox[{"BaseF", "[", 
         RowBox[{
          RowBox[{"Abs", "@", "fourier"}], ",", "scanf", ",", "samplerate", 
          ",", "precision", ",", "flimit"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{
       "(*", "\:91cd\:91c7\:6837\:524d\:7684\:57fa\:9891\:548c\:5171\:632f\
\:5cf0\:6570\:636e", "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"nlist", "=", 
        RowBox[{"Length", "[", "matrixn", "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"dn", "=", 
        RowBox[{"Floor", "[", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{
            RowBox[{"matrixn", "[", 
             RowBox[{"[", 
              RowBox[{"1", ",", "1"}], "]"}], "]"}], "+", "1"}], ")"}], "/", 
          "2"}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"nunit", "=", 
        FractionBox[
         RowBox[{"n", " ", "precision", " ", 
          RowBox[{"Range", "[", "nlist", "]"}]}], "samplerate"]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"nmid", "=", 
        RowBox[{
         RowBox[{"Floor", " ", "[", 
          RowBox[{"fbase", " ", "nunit"}], "]"}], "+", "1"}]}], ";", 
       RowBox[{
       "(*", "\:91cd\:91c7\:6837\:524d\:4e00\:7cfb\:5217\:6cdb\:97f3\:7684\
\:4f4d\:7f6e", "*)"}], "\[IndentingNewLine]", 
       RowBox[{"newnmid", "=", 
        RowBox[{
         RowBox[{"Floor", "[", 
          RowBox[{"fgoal", " ", "nunit"}], "]"}], "+", "1"}]}], ";", 
       RowBox[{"(*", 
        RowBox[{"\:91cd\:91c7\:6837\:540e", 
         RowBox[{"(", "\:76ee\:6807", ")"}], 
         "\:4e00\:7cfb\:5217\:6cdb\:97f3\:7684\:4f4d\:7f6e"}], "*)"}], 
       "\[IndentingNewLine]", 
       RowBox[{"function", "=", 
        RowBox[{"LineFunction", "[", 
         RowBox[{"matrixn", ",", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"{", 
             RowBox[{"0", ",", 
              RowBox[{"matrixn", "[", 
               RowBox[{"[", 
                RowBox[{"1", ",", "2"}], "]"}], "]"}]}], "}"}], ",", 
            RowBox[{"{", 
             RowBox[{
              RowBox[{"Max", "[", 
               RowBox[{
                RowBox[{"Floor", "[", 
                 FractionBox[
                  RowBox[{"n", " ", "precision"}], "2"], "]"}], ",", 
                RowBox[{"newnmid", "[", 
                 RowBox[{"[", 
                  RowBox[{"-", "1"}], "]"}], "]"}]}], "]"}], ",", 
              RowBox[{"matrixn", "[", 
               RowBox[{"[", 
                RowBox[{
                 RowBox[{"-", "1"}], ",", "2"}], "]"}], "]"}]}], "}"}]}], 
           "}"}], ",", "1"}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{
       "(*", "\:62df\:5408\:51fa\:91cd\:91c7\:6837\:524d\:7684\:5171\:632f\
\:5cf0\:51fd\:6570", "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"ampshiftlist", "=", 
        RowBox[{
         RowBox[{
          RowBox[{"Min", "[", 
           RowBox[{"#", ",", "15"}], "]"}], "&"}], "/@", 
         FractionBox[
          RowBox[{"function", "[", "newnmid", "]"}], 
          RowBox[{"function", "[", "nmid", "]"}]]}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
        "\:6839\:636e\:91cd\:91c7\:6837\:524d\:7684\:5171\:632f\:5cf0\:51fd\
\:6570", "\:ff0c", 
         "\:5f97\:5230\:6240\:9700\:7684\:632f\:5e45\:4fee\:6b63\:5e8f\:5217",
          "\:ff0c", 
         RowBox[{"(", 
          RowBox[{
          "\:76ee\:7684\:662f\:4e3a\:4e86\:4fdd\:8bc1\:91cd\:91c7\:6837\:540e\
", "\:ff0c", "\:5171\:632f\:5cf0\:7684\:5f62\:72b6\:4e0d\:53d8"}], ")"}], ",",
          "\:4e3a\:4e86\:51cf\:5c11\:566a\:58f0", "\:ff0c", 
         "\:4e0a\:9650\:662f\:653e\:592715\:500d"}], "*)"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"newfourier", "[", 
         RowBox[{"[", 
          RowBox[{"1", ";;", "dn"}], "]"}], "]"}], "=", 
        RowBox[{
         RowBox[{"ampshiftlist", "[", 
          RowBox[{"[", "1", "]"}], "]"}], 
         RowBox[{"fourier", "[", 
          RowBox[{"[", 
           RowBox[{"1", ";;", "dn"}], "]"}], "]"}]}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"Do", "[", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{
          RowBox[{
           RowBox[{"newfourier", "[", 
            RowBox[{"[", 
             RowBox[{
              RowBox[{
               RowBox[{"nmid", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "-", "dn"}], ";;", 
              RowBox[{
               RowBox[{"nmid", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "+", "dn"}]}], "]"}], "]"}], 
           "=", 
           RowBox[{
            RowBox[{"ampshiftlist", "[", 
             RowBox[{"[", "i", "]"}], "]"}], 
            RowBox[{"fourier", "[", 
             RowBox[{"[", 
              RowBox[{
               RowBox[{
                RowBox[{"nmid", "[", 
                 RowBox[{"[", "i", "]"}], "]"}], "-", "dn"}], ";;", 
               RowBox[{
                RowBox[{"nmid", "[", 
                 RowBox[{"[", "i", "]"}], "]"}], "+", "dn"}]}], "]"}], 
             "]"}]}]}], ";"}], "\[IndentingNewLine]", ",", 
         RowBox[{"{", 
          RowBox[{"i", ",", "1", ",", "nlist"}], "}"}]}], "]"}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{"\:5e94\:7528\:8be5\:4fee\:6b63", 
         RowBox[{
         "(", "\:4ee5\:4e0a\:8ff0\:632f\:5e45\:4fee\:6b63\:5e8f\:5217\:4f5c\
\:6ee4\:6ce2\:5668", ")"}]}], "*)"}], "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"newfourier", "[", 
         RowBox[{"[", 
          RowBox[{
           RowBox[{"1", "-", 
            RowBox[{"nmid", "[", 
             RowBox[{"[", 
              RowBox[{"-", "1"}], "]"}], "]"}], "-", "dn"}], ";;", 
           RowBox[{"-", "1"}]}], "]"}], "]"}], "=", 
        RowBox[{"Conjugate", "@", 
         RowBox[{"Reverse", "[", 
          RowBox[{"newfourier", "[", 
           RowBox[{"[", 
            RowBox[{"2", ";;", 
             RowBox[{
              RowBox[{"nmid", "[", 
               RowBox[{"[", 
                RowBox[{"-", "1"}], "]"}], "]"}], "+", "dn"}]}], "]"}], "]"}],
           "]"}]}]}], ";", 
       RowBox[{
       "(*", "\:522b\:5fd8\:4e86\:9891\:8c31\:6570\:636e\:8fd8\:6709\:53d6\
\:5171\:8f6d\:7684\:53e6\:5916\:4e00\:534a\:8fb9", "*)"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"newdata", "=", 
        RowBox[{
         RowBox[{"Re", "@", 
          RowBox[{
           RowBox[{"InverseFourier", "[", "newfourier", "]"}], "[", 
           RowBox[{"[", 
            RowBox[{";;", "n"}], "]"}], "]"}]}], "/", "windowlist"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
        "\:505aFourier\:9006\:53d8\:6362", ",", 
         "\:53bb\:6389\:7a97\:51fd\:6570"}], "*)"}], "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"newenergy", "=", 
        RowBox[{"Total", "[", 
         SuperscriptBox["newdata", "2"], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"(*", "\:6b64\:65f6\:7684\:603b\:80fd\:91cf", "*)"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{
        SuperscriptBox[
         RowBox[{"(", 
          RowBox[{"energy", "/", "newenergy"}], ")"}], "0.5"], 
        RowBox[{"Resample", "[", 
         RowBox[{"newdata", ",", 
          RowBox[{"fbase", "/", "fgoal"}]}], "]"}]}]}]}], 
     "\[IndentingNewLine]", 
     RowBox[{"(*", 
      RowBox[{
      "\:5e94\:7528\:91cd\:91c7\:6837", "\:ff0c", 
       "\:5e76\:4fdd\:6301\:524d\:540e\:80fd\:91cf\:4e0d\:53d8"}], "*)"}], 
     "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", 
   RowBox[{"(*", "\[IndentingNewLine]", 
    RowBox[{
    "KFResample\:51fd\:6570", "\:ff1a", "\[IndentingNewLine]", "\:8f93\:5165",
      "\:ff1a", 
     RowBox[{"data", "-", "\:4e00\:7ef4\:5b9e\:6570\:5217\:8868"}], ",", 
     RowBox[{"fgoal", "-", "\:6b63\:5b9e\:6570"}], ",", 
     RowBox[{"windowlist", "-", 
      RowBox[{"\:4e00\:7ef4\:5b9e\:6570\:5217\:8868", 
       RowBox[{"(", 
        RowBox[{
        "\:7a97\:51fd\:6570\:7684\:79bb\:6563\:5316", "\:ff0c", 
         "\:957f\:5ea6\:9700\:8981\:548c\:524d\:9762\:7684data\:76f8\:7b49"}],
         ")"}]}]}], "\:ff0c", 
     RowBox[{
     "\:5176\:5b83\:53c2\:6570\:4e0eBaseF\:51fd\:6570\:5b8c\:5168\:4e00\:6837\
", "\[IndentingNewLine]", "\:8f93\:51fa"}], "\:ff1a", 
     RowBox[{
     "\:4e00\:7ef4\:5b9e\:6570\:5217\:8868", "\[IndentingNewLine]", 
      "\:529f\:80fd"}], "\:ff1a", 
     RowBox[{"\:5c06\:4e00\:6bb5\:58f0\:97f3", 
      RowBox[{"(", "data", ")"}], 
      "\:91cd\:91c7\:6837\:81f3\:7ed9\:5b9a\:9891\:7387", 
      RowBox[{"(", "fgoal", ")"}]}], "\:ff0c", 
     RowBox[{"\:5e76\:4e14\:4fdd\:6301\:97f3\:8272\:4e0d\:53d8", 
      RowBox[{"(", "\:5171\:632f\:5cf0\:4fee\:6b63", ")"}]}]}], 
    "\[IndentingNewLine]", "*)"}], "\[IndentingNewLine]", 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Transition", "=", 
     RowBox[{"Compile", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"x1", ",", "_Real", ",", "1"}], "}"}], ",", 
         RowBox[{"{", 
          RowBox[{"x2", ",", "_Real", ",", "1"}], "}"}]}], "}"}], ",", 
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
           RowBox[{"n", "=", 
            RowBox[{"Length", "[", "x1", "]"}]}], ",", "\[Alpha]", ",", 
           RowBox[{"f1", "=", 
            RowBox[{"Fourier", "[", "x1", "]"}]}], ",", 
           RowBox[{"f2", "=", 
            RowBox[{"Fourier", "[", "x2", "]"}]}]}], "}"}], ",", 
         "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"\[Alpha]", "=", 
           RowBox[{
            SuperscriptBox[
             RowBox[{"(", 
              FractionBox["f2", 
               RowBox[{"f1", "+", 
                SuperscriptBox["2", 
                 RowBox[{"-", "62"}]], 
                RowBox[{
                "(*", "\:9632\:6b62\:88ab\:9664\:6570\:4e3a0", "*)"}]}]], 
              ")"}], 
             FractionBox["1", "n"]], "*", 
            SuperscriptBox["\[ExponentialE]", 
             RowBox[{"-", 
              FractionBox[
               RowBox[{"\[ImaginaryI]", " ", "2", "\[Pi]", " ", 
                RowBox[{"Range", "[", 
                 RowBox[{"0", ",", 
                  RowBox[{"n", "-", "1"}]}], "]"}]}], "n"]}]]}]}], ";", 
          RowBox[{
           RowBox[{"Table", "[", 
            RowBox[{
             RowBox[{"Total", "[", 
              RowBox[{"If", "[", 
               RowBox[{
                RowBox[{"i", "\[Equal]", "1"}], ",", 
                RowBox[{"Re", "[", "f1", "]"}], ",", 
                RowBox[{"Re", "[", 
                 RowBox[{"f1", "*=", "\[Alpha]"}], "]"}]}], "]"}], "]"}], ",", 
             RowBox[{"{", 
              RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}], "/", 
           SqrtBox["n"]}]}]}], "]"}], ",", 
       RowBox[{"\"\<RuntimeOptions\>\"", "\[Rule]", "\"\<Speed\>\""}]}], 
      "]"}]}], ";"}], "\[IndentingNewLine]", 
   RowBox[{"(*", 
    RowBox[{
    "\:8fc7\:6e21\:51fd\:6570", "\:ff1a", 
     "\:7ed9\:51fa\:5b9e\:6570\:6570\:7ec41\:548c\:5b9e\:6570\:6570\:7ec42", 
     "\:ff0c", 
     "\:8f93\:51fa\:4ece\:6570\:7ec41\:52302\:7684\:8fc7\:6e21\:6570\:7ec4", 
     ",", "\:7528\:4e8eSOLA\:7b97\:6cd5\:4e2d"}], "*)"}], 
   "\[IndentingNewLine]", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"DataJoin", "[", 
     RowBox[{"datalist_", ",", "nlist_", ",", "maxolp_", ",", "kmax_"}], 
     "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"ndata", "=", 
         RowBox[{"Length", "[", "datalist", "]"}]}], 
        RowBox[{"(*", "\:603b\:5e27\:6570", "*)"}], ",", 
        RowBox[{"nlt", "=", "nlist"}], 
        RowBox[{"(*", 
         RowBox[{
         "SOLA\:7b97\:6cd5\:662f\:4e0d\:5b9a\:65f6\:957f\:7684", ",", 
          "\:5373\:6bcf\:5e27\:7684\:6700\:7ec8\:8d77\:59cb\:4f4d\:7f6e\:4e0e\
\:521d\:59cb\:8d77\:59cb\:4f4d\:7f6e\:4e0d\:76f8\:7b49", "\:ff0c", 
          "\:56e0\:6b64\:6211\:4eec\:62f7\:8d1d\:4e00\:4efd\:7528\:4e8e\:4f4d\
\:7f6e\:4fee\:6539"}], "*)"}], ",", 
        RowBox[{"llt", "=", 
         RowBox[{
          RowBox[{
           RowBox[{"Length", "[", "#", "]"}], "&"}], "/@", "datalist"}]}], 
        RowBox[{"(*", "\:6bcf\:5e27\:7684\:957f\:5ea6\:5217\:8868", "*)"}], 
        ",", "output", ",", "olp", ",", "k", ",", "onelist", ",", "testlist", 
        ",", "convolvelist"}], "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"output", "=", 
        RowBox[{"ConstantArray", "[", 
         RowBox[{"0", ",", 
          RowBox[{
           RowBox[{"nlt", "[", 
            RowBox[{"[", 
             RowBox[{"-", "1"}], "]"}], "]"}], "+", 
           RowBox[{"llt", "[", 
            RowBox[{"[", 
             RowBox[{"-", "1"}], "]"}], "]"}], "+", "kmax", "+", 
           RowBox[{"2", "maxolp"}]}]}], "]"}]}], ";", 
       RowBox[{"(*", 
        RowBox[{
        "\:540c\:7406\:7531\:4e8e\:4e0d\:5b9a\:65f6\:957f", "\:ff0c", 
         "\:6211\:4eec\:5c06\:8f93\:51fa\:7684\:6570\:7ec4\:7684\:521d\:59cb\
\:957f\:5ea6\:7559\:4e00\:4e9b\:5bcc\:4f59\:9632\:6b62\:6ea2\:51fa"}], "*)"}],
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"output", "[", 
         RowBox[{"[", 
          RowBox[{
           RowBox[{
            RowBox[{"nlt", "[", 
             RowBox[{"[", "1", "]"}], "]"}], "+", "1"}], ";;", 
           RowBox[{
            RowBox[{"nlt", "[", 
             RowBox[{"[", "1", "]"}], "]"}], "+", 
            RowBox[{"llt", "[", 
             RowBox[{"[", "1", "]"}], "]"}]}]}], "]"}], "]"}], "=", 
        RowBox[{"datalist", "[", 
         RowBox[{"[", "1", "]"}], "]"}]}], ";", 
       RowBox[{
       "(*", "\:7b2c\:4e00\:5e27\:7167\:6284\:81f3\:76ee\:6807\:4f4d\:7f6e", 
        "*)"}], "\[IndentingNewLine]", 
       RowBox[{"Do", "[", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{
          RowBox[{"olp", "=", 
           RowBox[{"Min", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"nlt", "[", 
               RowBox[{"[", 
                RowBox[{"i", "-", "1"}], "]"}], "]"}], "+", 
              RowBox[{"llt", "[", 
               RowBox[{"[", 
                RowBox[{"i", "-", "1"}], "]"}], "]"}], "-", 
              RowBox[{"nlt", "[", 
               RowBox[{"[", "i", "]"}], "]"}]}], ",", 
             RowBox[{"llt", "[", 
              RowBox[{"[", "i", "]"}], "]"}], ",", "maxolp"}], "]"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"olp", "<", "1"}], ",", 
            RowBox[{"Return", "[", 
             RowBox[{"{", "}"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", 
          RowBox[{"k", "=", 
           RowBox[{"Min", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"nlt", "[", 
               RowBox[{"[", 
                RowBox[{"i", "-", "1"}], "]"}], "]"}], "+", 
              RowBox[{"llt", "[", 
               RowBox[{"[", 
                RowBox[{"i", "-", "1"}], "]"}], "]"}], "-", 
              RowBox[{"nlt", "[", 
               RowBox[{"[", "i", "]"}], "]"}], "-", "olp"}], ",", "kmax"}], 
            "]"}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"onelist", "=", 
           RowBox[{"ConstantArray", "[", 
            RowBox[{"1", ",", "olp"}], "]"}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{
             RowBox[{
              RowBox[{"nlt", "[", 
               RowBox[{"[", "i", "]"}], "]"}], "+", "1", "-", 
              RowBox[{"2", "kmax"}], "+", "k"}], "<", "1"}], ",", 
            RowBox[{"Return", "[", 
             RowBox[{"{", "}"}], "]"}]}], "]"}], ";", "\[IndentingNewLine]", 
          RowBox[{"testlist", "=", 
           RowBox[{"output", "[", 
            RowBox[{"[", 
             RowBox[{
              RowBox[{
               RowBox[{"nlt", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "+", "1", "-", 
               RowBox[{"2", "kmax"}], "+", "k"}], ";;", 
              RowBox[{
               RowBox[{"nlt", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "+", "olp", "+", "k"}]}], 
             "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"convolvelist", "=", 
           FractionBox[
            RowBox[{"ListCorrelate", "[", 
             RowBox[{
              RowBox[{"datalist", "[", 
               RowBox[{"[", 
                RowBox[{"i", ",", 
                 RowBox[{";;", "olp"}]}], "]"}], "]"}], ",", "testlist"}], 
             "]"}], 
            RowBox[{
             SuperscriptBox[
              RowBox[{"ListConvolve", "[", 
               RowBox[{"onelist", ",", 
                SuperscriptBox["testlist", "2"]}], "]"}], "0.5"], "+", 
             SuperscriptBox["2", 
              RowBox[{"-", "56"}]], 
             RowBox[{
             "(*", "\:9632\:6b62\:88ab\:9664\:6570\:4e3a0", "*)"}]}]]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"(*", "\:4f5c\:81ea\:76f8\:5173\:68c0\:6d4b", "*)"}], 
          "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"nlt", "[", 
            RowBox[{"[", "i", "]"}], "]"}], "=", 
           RowBox[{
            RowBox[{"nlt", "[", 
             RowBox[{"[", "i", "]"}], "]"}], "+", 
            RowBox[{
             RowBox[{"Ordering", "[", 
              RowBox[{"convolvelist", ",", 
               RowBox[{"-", "1"}]}], "]"}], "[", 
             RowBox[{"[", "1", "]"}], "]"}], "+", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{
               RowBox[{"-", "2"}], "kmax"}], "+", "k", "-", "1"}], ")"}]}]}], 
          ";", "\[IndentingNewLine]", 
          RowBox[{"(*", 
           RowBox[{
           "\:6839\:636e\:4e0a\:8ff0\:6700\:5927\:81ea\:76f8\:5173\:7684\:4f4d\
\:7f6e", "\:ff0c", 
            "\:9002\:5f53\:4fee\:6b63\:76ee\:6807\:5e27\:7684\:8d77\:59cb\
\:4f4d\:7f6e"}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"output", "[", 
            RowBox[{"[", 
             RowBox[{
              RowBox[{
               RowBox[{"nlt", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "+", "1"}], ";;", 
              RowBox[{
               RowBox[{"nlt", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "+", "olp"}]}], "]"}], "]"}], 
           "=", 
           RowBox[{"Transition", "[", 
            RowBox[{
             RowBox[{"output", "[", 
              RowBox[{"[", 
               RowBox[{
                RowBox[{
                 RowBox[{"nlt", "[", 
                  RowBox[{"[", "i", "]"}], "]"}], "+", "1"}], ";;", 
                RowBox[{
                 RowBox[{"nlt", "[", 
                  RowBox[{"[", "i", "]"}], "]"}], "+", "olp"}]}], "]"}], 
              "]"}], ",", 
             RowBox[{"datalist", "[", 
              RowBox[{"[", 
               RowBox[{"i", ",", 
                RowBox[{";;", "olp"}]}], "]"}], "]"}]}], "]"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"(*", 
           RowBox[{
           "\:83b7\:5f97\:6700\:7ec8\:8d77\:59cb\:4f4d\:7f6e\:540e", "\:ff0c",
             "\:524d\:9762\:7684\:90e8\:5206\:5e94\:7528\:8fc7\:6e21\:51fd\
\:6570", ",", "\:6539\:5584\:97f3\:9891\:542c\:611f"}], "*)"}], 
          "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"output", "[", 
            RowBox[{"[", 
             RowBox[{
              RowBox[{
               RowBox[{"nlt", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "+", "olp", "+", "1"}], ";;", 
              RowBox[{
               RowBox[{"nlt", "[", 
                RowBox[{"[", "i", "]"}], "]"}], "+", 
               RowBox[{"llt", "[", 
                RowBox[{"[", "i", "]"}], "]"}]}]}], "]"}], "]"}], "=", 
           RowBox[{"datalist", "[", 
            RowBox[{"[", 
             RowBox[{"i", ",", 
              RowBox[{
               RowBox[{"olp", "+", "1"}], ";;"}]}], "]"}], "]"}]}]}], 
         "\[IndentingNewLine]", 
         RowBox[{
         "(*", "\:540e\:9762\:7684\:90e8\:5206\:76f4\:63a5\:7167\:6284", 
          "*)"}], "\[IndentingNewLine]", ",", 
         RowBox[{"{", 
          RowBox[{"i", ",", "2", ",", "ndata"}], "}"}]}], "]"}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"output", "[", 
        RowBox[{"[", 
         RowBox[{";;", 
          RowBox[{
           RowBox[{"nlt", "[", 
            RowBox[{"[", 
             RowBox[{"-", "1"}], "]"}], "]"}], "+", 
           RowBox[{"llt", "[", 
            RowBox[{"[", 
             RowBox[{"-", "1"}], "]"}], "]"}]}]}], "]"}], "]"}]}]}], 
     RowBox[{"(*", 
      RowBox[{
      "\:6b64\:65f6\:603b\:957f\:5df2\:786e\:5b9a", ",", 
       "\:7ed3\:679c\:53ef\:76f4\:63a5\:8f93\:51fa"}], "*)"}], "]"}]}], 
   "\[IndentingNewLine]", 
   RowBox[{"(*", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{
     "DataJoin\:51fd\:6570", ":", "\[IndentingNewLine]", "\:8f93\:5165", ":", 
      RowBox[{"datalist", "-", 
       RowBox[{"\:4e8c\:7ef4\:5b9e\:6570\:5217\:8868", 
        RowBox[{"(", 
         RowBox[{
         "\:4ee3\:8868\:5404\:97f3\:9891\:5e27\:7684\:632f\:5e45\:6570\:7ec4",
           "\:ff0c", "\:6bcf\:5e27\:53ef\:4e0d\:7b49\:957f"}], ")"}]}]}]}], 
     ",", "\[IndentingNewLine]", 
     RowBox[{"nlist", "-", 
      RowBox[{"\:4e00\:7ef4\:6b63\:6574\:6570\:5217\:8868", 
       RowBox[{"(", 
        RowBox[{
        "\:4ee3\:8868\:6bcf\:5e27\:7684\:521d\:59cb\:8d77\:59cb\:4f4d\:7f6e", 
         RowBox[{
         "(", "\:51b3\:5b9a\:4e86\:8f93\:51fa\:97f3\:9891\:7684\:65f6\:57df\
\:62c9\:4f38\:7a0b\:5ea6", ")"}]}], ")"}]}]}], ",", 
     RowBox[{"maxolp", "-", 
      RowBox[{"\:6b63\:6574\:6570", 
       RowBox[{"(", 
        RowBox[{
        "\:5e94\:7528Trasition\:8fc7\:6e21\:51fd\:6570\:7684\:6700\:5927\:957f\
\:5ea6", ",", 
         RowBox[{
         "\:6700\:4f73\:53d6\:503c\:8ddf\:6bcf\:5e27\:7684\:957f\:5ea6\:4ee5\
\:53ca\:97f3\:9891\:7684\:62c9\:4f38\:60c5\:51b5", 
          RowBox[{"(", "nlist\:4e2d\:76f8\:90bb\:6570\:7684\:5dee", ")"}], 
          "\:6709\:5173"}], "\:ff0c", 
         RowBox[{"\:4e00\:822c\:53d6\:503c\:5728256", "-", 
          RowBox[{"1024", "\:4e4b\:95f4"}]}]}], ")"}]}]}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"kmax", "-", "\:6b63\:6574\:6570"}]}], 
    RowBox[{"(*", 
     RowBox[{
     "\:6700\:5927\:641c\:7d22\:8303\:56f4", ",", 
      "\:503c\:8d8a\:5927\:97f3\:9891\:8fde\:7eed\:6027\:8d8a\:597d\:4f46\
\:6bcf\:5e27\:7684\:65f6\:95f4\:8bef\:5dee\:5219\:8d8a\:5927", "\:ff0c", 
      "\:5bf9\:4e8e44100Hz\:91c7\:6837\:7387\:63a8\:8350100"}], "*)"}], 
    "\[IndentingNewLine]", "*)"}], "\[IndentingNewLine]", 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"FSQ", "[", "f_", "]"}], ":=", 
    RowBox[{
     RowBox[{
      RowBox[{"f", "[", 
       RowBox[{"[", "0", "]"}], "]"}], "===", "Function"}], "||", 
     RowBox[{
      RowBox[{"f", "[", 
       RowBox[{"[", "0", "]"}], "]"}], "===", "Symbol"}], "||", 
     RowBox[{
      RowBox[{"f", "[", 
       RowBox[{"[", "0", "]"}], "]"}], "===", "InterpolatingFunction"}]}]}], 
   "\[IndentingNewLine]", 
   RowBox[{"(*", 
    RowBox[{
    "\:5224\:65ad\:4e00\:4e2a\:8f93\:5165\:7684\:7c7b\:578b\:662f\:5426\:662f\
\:7eaf\:51fd\:6570", "\:3001", "\:7b26\:53f7\:6216\:63d2\:503c\:51fd\:6570"}],
     "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{
     RowBox[{"FTShift", "[", 
      RowBox[{"fgoal_", ",", 
       RowBox[{"tgoal_:", "Identity"}], ",", 
       RowBox[{"flo_:", "150"}], ",", 
       RowBox[{"fup_:", "400"}], ",", 
       RowBox[{"width_:", "2048"}], ",", 
       RowBox[{"shift_:", "512"}], ",", 
       RowBox[{"maxolp_:", "256"}], ",", 
       RowBox[{"kmax_:", "100"}], ",", 
       RowBox[{"flimit_:", "8000"}], ",", 
       RowBox[{"windowfunction_:", "Hamming"}], ",", 
       RowBox[{"samplerate_:", "44100"}], ",", 
       RowBox[{"precision_:", "8"}]}], "]"}], "[", 
     RowBox[{"data_", ",", 
      RowBox[{"scant_:", 
       RowBox[{"{", 
        RowBox[{"0", ",", "\[Infinity]"}], "}"}]}]}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"n", "=", "0"}], ",", "windowlist", ",", "ns", ",", "n1", ",",
         "n2", ",", "partition", ",", "tlist", ",", "tgoallist", ",", 
        "fgoallist", ",", "scanflist"}], "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"windowlist", "=", 
        RowBox[{"Windowlist", "[", 
         RowBox[{"width", ",", "windowfunction"}], "]"}]}], ";", 
       RowBox[{"(*", "\:79bb\:6563\:5316\:7a97\:51fd\:6570", "*)"}], 
       "\[IndentingNewLine]", 
       RowBox[{"ns", "=", 
        RowBox[{"Length", "[", "data", "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"n1", "=", 
        RowBox[{
         RowBox[{"Max", "[", 
          RowBox[{
           RowBox[{"Floor", "[", 
            RowBox[{"samplerate", " ", 
             RowBox[{"scant", "[", 
              RowBox[{"[", "1", "]"}], "]"}]}], "]"}], ",", "0"}], "]"}], "+",
          "1"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"n2", "=", 
        RowBox[{"Min", "[", 
         RowBox[{
          RowBox[{"Floor", "[", 
           RowBox[{"samplerate", " ", 
            RowBox[{"scant", "[", 
             RowBox[{"[", "2", "]"}], "]"}]}], "]"}], ",", "ns"}], "]"}]}], 
       ";", "\[IndentingNewLine]", 
       RowBox[{
       "(*", "\:83b7\:5f97\:622a\:53d6\:97f3\:9891\:7684\:4f4d\:7f6e", "*)"}],
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"partition", "=", 
        RowBox[{"Partition", "[", 
         RowBox[{"data", ",", "width", ",", "shift", ",", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{
             RowBox[{"-", "width"}], "-", "n1", "+", "1"}], ",", 
            RowBox[{"ns", "-", "n2", "+", "1"}]}], "}"}], ",", "0"}], "]"}]}],
        ";", "\[IndentingNewLine]", 
       RowBox[{"(*", "\:5f97\:5230\:91cd\:53e0\:5e27\:5e8f\:5217", "*)"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"n", "=", 
        RowBox[{"Length", "[", "partition", "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"(*", "\:91cd\:53e0\:5e27\:603b\:6570", "*)"}], 
       "\[IndentingNewLine]", 
       RowBox[{"tlist", "=", 
        RowBox[{"Range", "[", 
         RowBox[{"0", ",", "1", ",", 
          FractionBox["1", 
           RowBox[{"n", "-", "1"}]]}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"tgoallist", "=", 
        RowBox[{"tgoal", "/@", "tlist"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{
       "(*", "\:6bcf\:5e27\:7684\:65f6\:95f4\:653e\:5927\:6bd4\:4f8b", "*)"}],
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"fgoallist", "=", 
        RowBox[{
         RowBox[{
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"FSQ", "[", "fgoal", "]"}], ",", 
            RowBox[{"fgoal", "[", 
             FractionBox["#", 
              RowBox[{"tgoal", "[", "1", "]"}]], "]"}], ",", "fgoal"}], "]"}],
           "&"}], "/@", "tgoallist"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"(*", "\:6bcf\:5e27\:7684\:76ee\:6807\:9891\:7387", "*)"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"scanflist", "=", 
        RowBox[{
         RowBox[{
          RowBox[{"{", 
           RowBox[{
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"FSQ", "[", "flo", "]"}], ",", 
              RowBox[{"flo", "[", "#", "]"}], ",", "flo"}], "]"}], ",", 
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"FSQ", "[", "fup", "]"}], ",", 
              RowBox[{"fup", "[", "#", "]"}], ",", "fup"}], "]"}]}], "}"}], 
          "&"}], "/@", "tlist"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{
       "(*", "\:6bcf\:5e27\:7684\:63a2\:6d4b\:9891\:7387\:4e0b\:9650\:548c\
\:63a2\:6d4b\:9891\:7387\:4e0a\:9650", "*)"}], "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"DataJoin", "[", 
        RowBox[{
         RowBox[{"ParallelTable", "[", 
          RowBox[{
           RowBox[{"KFResample", "[", 
            RowBox[{
             RowBox[{"partition", "[", 
              RowBox[{"[", "i", "]"}], "]"}], ",", 
             RowBox[{"fgoallist", "[", 
              RowBox[{"[", "i", "]"}], "]"}], ",", "windowlist", ",", 
             RowBox[{"scanflist", "[", 
              RowBox[{"[", "i", "]"}], "]"}], ",", "flimit", ",", 
             "samplerate", ",", "precision"}], "]"}], ",", 
           RowBox[{"{", 
            RowBox[{"i", ",", "1", ",", "n"}], "}"}]}], "]"}], ",", 
         RowBox[{"Round", "[", 
          RowBox[{"n", " ", "shift", " ", "tgoallist"}], "]"}], 
         RowBox[{
         "(*", "\:6bcf\:5e27\:7684\:521d\:59cb\:8d77\:59cb\:4f4d\:7f6e", 
          "*)"}], ",", "maxolp", ",", "kmax"}], "]"}]}]}], "]"}]}], 
   "\[IndentingNewLine]", 
   RowBox[{"(*", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{
     "FTShift\:51fd\:6570", ":", "\[IndentingNewLine]", "\:8f93\:5165", ":", 
      RowBox[{"fgoal", "-", 
       RowBox[{"\:6b63\:5b9e\:6570\:6216", "[", 
        RowBox[{"0", ",", "1"}], "]"}], "-", 
       RowBox[{
        SuperscriptBox["R", "+"], "\:4e0a\:7684\:51fd\:6570", 
        RowBox[{
        "(", "\:4ee3\:8868\:76ee\:6807\:9891\:7387\:6216\:76ee\:6807\:9891\
\:7387\:66f2\:7ebf", ")"}]}]}]}], ",", "\[IndentingNewLine]", 
     RowBox[{"tgoal", "-", 
      RowBox[{"[", 
       RowBox[{"0", ",", "1"}], "]"}], "-", 
      RowBox[{
       SuperscriptBox["R", "+"], 
       "\:4e0a\:7684\:5355\:8c03\:9012\:589e\:51fd\:6570", 
       RowBox[{
       "(", "\:4ee3\:8868\:97f3\:9891\:7684\:76ee\:6807\:62c9\:4f38", 
        ")"}]}]}], ",", "\[IndentingNewLine]", 
     RowBox[{"flo", "-", 
      RowBox[{"\:6b63\:5b9e\:6570\:6216", "[", 
       RowBox[{"0", ",", "1"}], "]"}], "-", 
      RowBox[{
       SuperscriptBox["R", "+"], "\:4e0a\:7684\:51fd\:6570", 
       RowBox[{"(", 
        RowBox[{
        "\:4ee3\:8868\:63a2\:6d4b\:9891\:7387\:4e0b\:9650\:6216\:63a2\:6d4b\
\:9891\:7387\:4e0b\:9650\:66f2\:7ebf", ",", "\:63a8\:8350150"}], ")"}]}]}], 
     ",", "\[IndentingNewLine]", 
     RowBox[{"fup", "-", 
      RowBox[{"\:6b63\:5b9e\:6570\:6216", "[", 
       RowBox[{"0", ",", "1"}], "]"}], "-", 
      RowBox[{
       SuperscriptBox["R", "+"], "\:4e0a\:7684\:51fd\:6570", 
       RowBox[{"(", 
        RowBox[{
        "\:4ee3\:8868\:63a2\:6d4b\:9891\:7387\:4e0a\:9650\:6216\:63a2\:6d4b\
\:9891\:7387\:4e0a\:9650\:66f2\:7ebf", ",", "\:63a8\:8350400"}], ")"}]}]}], 
     ",", "\[IndentingNewLine]", 
     RowBox[{"width", "-", 
      RowBox[{"\:6b63\:6574\:6570", 
       RowBox[{"(", 
        RowBox[{
        "\:91cd\:91c7\:6837\:524d\:6bcf\:91cd\:53e0\:5e27\:7684\:5207\:5206\
\:5bbd\:5ea6", ",", "\:63a8\:83502048\:5de6\:53f3"}], ")"}]}]}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"shift", "-", 
      RowBox[{"\:6b63\:6574\:6570", 
       RowBox[{"(", 
        RowBox[{
        "\:91cd\:91c7\:6837\:524d\:76f8\:90bb\:91cd\:53e0\:5e27\:4e4b\:95f4\
\:7684\:8ddd\:79bb", ",", 
         "\:5fc5\:987b\:5c0f\:4e8ewidth\:5426\:5219\:65e0\:6cd5\:91cd\:53e0", 
         ",", 
         RowBox[{
          RowBox[{
           RowBox[{"\:4e00\:822c\:53d6\:5728width\:76841", "/", 
            RowBox[{"8", "~", "1"}]}], "/", "2"}], "\:4e4b\:95f4", 
          RowBox[{"(", 
           RowBox[{"256", "~", "1024"}], ")"}]}]}], ")"}]}]}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"windowfunction", "-", 
      RowBox[{"[", 
       RowBox[{"0", ",", "1"}], "]"}], "-", 
      RowBox[{"R\:4e0a\:7684\:51fd\:6570", 
       RowBox[{"(", "\:7a97\:51fd\:6570", ")"}]}]}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"data", "-", 
      RowBox[{"\:4e00\:7ef4\:5b9e\:6570\:5217\:8868", 
       RowBox[{"(", "\:97f3\:9891\:632f\:5e45\:6570\:636e", ")"}]}]}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"scant", "-", 
      RowBox[{"\:5b9e\:6570\:5bf9", 
       RowBox[{
       "(", "\:8868\:793a\:622a\:53d6\:7684\:88ab\:5904\:7406\:97f3\:9891\
\:7684\:65f6\:95f4\:8303\:56f4", ")"}]}]}], ",", "\[IndentingNewLine]", 
     RowBox[{
     "\:5176\:4f59\:53c2\:6570\:89c1BaseF\:51fd\:6570\:548cDataJoin\:51fd\
\:6570\:4e2d\:7684\:5b9a\:4e49", "\[IndentingNewLine]", 
      RowBox[{"\:8f93\:51fa", ":", 
       RowBox[{"\:4e00\:7ef4\:5b9e\:6570\:5217\:8868", 
        RowBox[{
        "(", "\:5904\:7406\:540e\:7684\:97f3\:9891\:632f\:5e45\:6570\:636e", 
         ")"}], "\[IndentingNewLine]", "\:529f\:80fd"}], ":", 
       RowBox[{
       "\:5728\:4fdd\:6301\:97f3\:8272\:7684\:60c5\:51b5\:4e0b\:6309\:7167\
\:9700\:6c42\:5bf9\:97f3\:9891\:8fdb\:884c\:4efb\:610f", 
        RowBox[{
        "(", "\:5747\:53ef\:8868\:793a\:6210\:51fd\:6570\:7684\:5f62\:5f0f", 
         ")"}], "\:7684\:53d8\:8c03\:548c\:53d8\:901f\:5904\:7406"}]}]}]}], 
    "\[IndentingNewLine]", "*)"}]}]}]], "Input",
 CellChangeTimes->{{3.7208502895263805`*^9, 3.720850362229767*^9}, {
   3.7208504003010755`*^9, 3.7208506360603538`*^9}, {3.720850679063422*^9, 
   3.7208507973281784`*^9}, {3.7208508650992155`*^9, 3.720850882499494*^9}, {
   3.7208509350001583`*^9, 3.7208509875148077`*^9}, 3.720851065318677*^9, {
   3.720851102486412*^9, 3.720851114101026*^9}, {3.7208511953122416`*^9, 
   3.7208512797469006`*^9}, {3.7208513117713594`*^9, 3.720851373221529*^9}, {
   3.720851412368396*^9, 3.72085143022875*^9}, {3.7208514851077137`*^9, 
   3.7208515569005423`*^9}, {3.720851634627884*^9, 3.7208516712515316`*^9}, {
   3.7208517159201*^9, 3.7208518078027377`*^9}, {3.7208518385778036`*^9, 
   3.720851997306985*^9}, {3.7208520857591195`*^9, 3.7208521672929397`*^9}, {
   3.7208521985135956`*^9, 3.7208522060653*^9}, {3.7208522476132965`*^9, 
   3.720852791933284*^9}, {3.72085617818132*^9, 3.720856215144039*^9}, {
   3.7208570202086115`*^9, 3.72085702470238*^9}, {3.7208624657292767`*^9, 
   3.720862536490996*^9}, {3.720862591698892*^9, 3.7208630427118797`*^9}, {
   3.7208630941350985`*^9, 3.7208632035284367`*^9}, {3.720863250041994*^9, 
   3.7208634765330095`*^9}, {3.7208635095487556`*^9, 3.720863577503641*^9}, {
   3.720863607599594*^9, 3.720863646162879*^9}, {3.7208637003016396`*^9, 
   3.7208637025684357`*^9}, 3.720863765338209*^9, {3.720863879188006*^9, 
   3.720863885637438*^9}, {3.7208639456258807`*^9, 3.7208642053844805`*^9}, {
   3.7208642535494666`*^9, 3.7208644158407125`*^9}, {3.7208644644412346`*^9, 
   3.7208644649014235`*^9}, 3.720864502279497*^9, {3.720864556326445*^9, 
   3.7208646006675034`*^9}, {3.72086464122598*^9, 3.7208646460519595`*^9}, 
   3.7208647235851145`*^9, {3.7208648205220633`*^9, 3.720864930965824*^9}, {
   3.7208649765861177`*^9, 3.7208654997559013`*^9}, {3.72086556093745*^9, 
   3.7208655658703504`*^9}, {3.7208656437995324`*^9, 
   3.7208656928337803`*^9}, {3.720865847595605*^9, 3.720865854752222*^9}, {
   3.7208659129698915`*^9, 3.7208659609497356`*^9}, {3.7208660149545026`*^9, 
   3.7208660457205315`*^9}, {3.720866085417291*^9, 3.720866498058242*^9}, {
   3.7208669311454244`*^9, 3.7208669361561546`*^9}, {3.7208703379317455`*^9, 
   3.720870338796458*^9}, {3.720870866086733*^9, 
   3.7208708769865465`*^9}},ExpressionUUID->"8e5ca69c-a10d-42cd-b096-\
fee295fddcf9"]
},
WindowSize->{1280, 637},
WindowMargins->{{-8, Automatic}, {Automatic, -8}},
Magnification->1.5,
FrontEndVersion->"11.2 for Microsoft Windows (64-bit) (2017\:5e7410\:67082\
\:65e5)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[558, 20, 66114, 1590, 11362, "Input",ExpressionUUID->"8e5ca69c-a10d-42cd-b096-fee295fddcf9"]
}
]
*)

